﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HRM.Models;

namespace HRM.Controllers.DangKy
{
    public class DangKy_GiangDayNgoaiTruongController : Controller
    {
        private HRMTTNS41Context db = new HRMTTNS41Context();

        //
        // GET: /DangKy_GiangDayNgoaiTruong/

        public ActionResult Index()
        {
            var dk_giangdayngoaitruong = db.dk_GiangDayNgoaiTruong;
            return View(dk_giangdayngoaitruong.ToList());
        }

        //
        // GET: /DangKy_GiangDayNgoaiTruong/Details/5

        public ActionResult Details(int id = 0)
        {
            dk_GiangDayNgoaiTruong dk_giangdayngoaitruong = db.dk_GiangDayNgoaiTruong.Find(id);
            if (dk_giangdayngoaitruong == null)
            {
                return HttpNotFound();
            }
            return View(dk_giangdayngoaitruong);
        }

        //
        // GET: /DangKy_GiangDayNgoaiTruong/Create

        public ActionResult Create()
        {
            ViewBag.MaDDKy = new SelectList(db.DotDK_TK, "MaDDKy", "TenDDKy");
            return View();
        }

        //
        // POST: /DangKy_GiangDayNgoaiTruong/Create

        [HttpPost]
        public ActionResult Create(dk_GiangDayNgoaiTruong dk_giangdayngoaitruong)
        {
            if (ModelState.IsValid)
            {
                db.dk_GiangDayNgoaiTruong.Add(dk_giangdayngoaitruong);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MaDDKy = new SelectList(db.DotDK_TK, "MaDDKy", "TenDDKy", dk_giangdayngoaitruong.MaDDKy);
            return View(dk_giangdayngoaitruong);
        }

        //
        // GET: /DangKy_GiangDayNgoaiTruong/Edit/5

        public ActionResult Edit(int id = 0)
        {
            dk_GiangDayNgoaiTruong dk_giangdayngoaitruong = db.dk_GiangDayNgoaiTruong.Find(id);
            if (dk_giangdayngoaitruong == null)
            {
                return HttpNotFound();
            }
            ViewBag.MaDDKy = new SelectList(db.DotDK_TK, "MaDDKy", "TenDDKy", dk_giangdayngoaitruong.MaDDKy);
            return View(dk_giangdayngoaitruong);
        }

        //
        // POST: /DangKy_GiangDayNgoaiTruong/Edit/5

        [HttpPost]
        public ActionResult Edit(dk_GiangDayNgoaiTruong dk_giangdayngoaitruong)
        {
            if (ModelState.IsValid)
            {
                db.Entry(dk_giangdayngoaitruong).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.MaDDKy = new SelectList(db.DotDK_TK, "MaDDKy", "TenDDKy", dk_giangdayngoaitruong.MaDDKy);
            return View(dk_giangdayngoaitruong);
        }

        //
        // GET: /DangKy_GiangDayNgoaiTruong/Delete/5

        public ActionResult Delete(int id = 0)
        {
            dk_GiangDayNgoaiTruong dk_giangdayngoaitruong = db.dk_GiangDayNgoaiTruong.Find(id);
            if (dk_giangdayngoaitruong == null)
            {
                return HttpNotFound();
            }
            return View(dk_giangdayngoaitruong);
        }

        //
        // POST: /DangKy_GiangDayNgoaiTruong/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            dk_GiangDayNgoaiTruong dk_giangdayngoaitruong = db.dk_GiangDayNgoaiTruong.Find(id);
            db.dk_GiangDayNgoaiTruong.Remove(dk_giangdayngoaitruong);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}